#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <string.h>
#include <stdio.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	int aa[1010] = { 0 };
	for (int i = 0; i < n; i++)
	{
		int temp;
		cin >> temp;
		for (int j = 0; j < temp; j++)
		{
			int temp2;
			cin >> temp2;
			aa[temp2]++;
		}
	}
	int max = 0;
	for (int i = 0; i < 1001; i++)
	{
		if (aa[i] >= aa[max])
			max = i;
//		cout << aa[max] << " " << max << endl;
	}
	cout << max << " " << aa[max];
	system("PAUSE");
	return 0;
}